<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
		<title>新建/修改模板</title>
		<link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
		<link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="/static/web/css/admin.css">
		<link rel="stylesheet" href="/static/web/css/codemirror.css">
		<script src="/static/web/js/codemirror.js"></script>
		<script src="/static/web/js/mode/xml/xml.js"></script>
		<script src="/static/web/js/mode/javascript/javascript.js"></script>
		<script src="/static/web/js/mode/css/css.js"></script>
		<script src="/static/web/js/mode/htmlmixed/htmlmixed.js"></script>
	</head>
	<body>
		<div class="container-fluid">
			<ol class="breadcrumb">
				<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li>
				<li class="breadcrumb-item"><a href="templets_main.php">默认模板管理</a></li>
				<li class="breadcrumb-item active">新建/修改模板</li>
			</ol>
			<div class="card shadow-sm">
				<div class="card-header">新建/修改模板</div>
				<div class="card-body">
					<form name="form1" action="tpl.php" method="post">
						<input type="hidden" name="action" value="saveedit">
						<input type="hidden" name="acdir" value="<?php echo $acdir;?>">
						<input type="hidden" name="_csrf_token" value="<?php echo $GLOBALS['csrf_token'];?>">
						<div class="table-responsive">
							<table class="table table-borderless">
								<tbody>
									<tr>
										<td width="260">文件名称</td>
										<td><input name="filename" value="<?php echo $filename;?>" class="admin-input-lg" required>（不可以用小数点..表示路径）</td>
									</tr>
									<tr>
										<td colspan="2">
										<?php
										foreach ($helps as $key => $help) {
											echo '<a href="javascript:showdiv(\''.$key.'\');" title="'.trim($help[0]).'" class="btn btn-light btn-sm">'.$key.'</a>'."";
										}
										?>
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<?php
											foreach ($helps as $key => $help) {
												echo '<div id="'.$key.'" class="helpinfo"><span class="float-right"><a href="javascript:;" onclick="showdiv(\'\');" class="btn btn-success btn-sm">关闭</a></span><p>标签名称：'.$key.'</p><p>标签说明：'.trim($help[0]).'</p><p><textarea id="'.$key.'" class="admin-textarea-xl">'.trim($help[1]).'</textarea></p><span>'."";
												$parameters = explode("\n", $help[2]);
												foreach($parameters as $parameter)
												{
													$parameter = trim($parameter);
													if ($parameter == "") continue;
													else echo $parameter,'<br>';
												}
												echo '</span></div>'."";
											}
											?>
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<textarea name="content" id="content"><?php echo $content;?></textarea>
										</td>
									</tr>
									<tr>
										<td colspan="2" align="center">
											<button type="submit" class="btn btn-success btn-sm">保存</button>
											<button type="reset" class="btn btn-outline-success btn-sm">重置</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script>
			function showdiv(id) {
				hideobj = GETNAMES("helpinfo");
				for (i = 0; i < hideobj.length; i++) {
					hideobj[i].style.display = "none";
				}
				if (id != '') {
					document.getElementById(id).style.display = "block";
				}
			}
			function GETNAMES(name) {
				var returns = document.getElementsByClassName(name);
				if (returns.length > 0) return returns;
				returns = new Array();
				var e = document.getElementsByTagName("div");
				for (i = 0; i < e.length; i++) {
					if (e[i].getAttribute("name") == name) {
						returns[returns.length] = e[i];
					}
				}
				return returns;
			}
			var editor = CodeMirror.fromTextArea(document.getElementById("content"), {
				lineNumbers: true,
				lineWrapping: true,
				mode: 'text/html',
			});
		</script>
	</body>
</html>